package A1_2;

import java.util.ArrayList;
import java.util.List;


// College 类，表示学院，包含多个建筑
class College {
    private String name;
    private List<Building> buildings;

    public College(String name) {
        this.name = name;
        this.buildings = new ArrayList<>();
    }

    public String getName() {
        return name;
    }

    public void addBuilding(Building building) {
        buildings.add(building);
    }

    public List<Building> getBuildings() {
        return buildings;
    }

    // 查找特定名称的课程
    public Course findCourseByName(String courseName) {
        for (Building building : buildings) {
            for (Course course : building.getCourses()) {
                if (course.getName().equals(courseName)) {
                    return course;
                }
            }
        }
        return null; // 如果没有找到，返回null
    }

    // 查找特定建筑的课程
    public List<Course> findCoursesInBuilding(String buildingName) {
        List<Course> courses = new ArrayList<>();
        for (Building building : buildings) {
            if (building.getName().equals(buildingName)) {
                courses.addAll(building.getCourses());
                break; // 假设建筑名称是唯一的，找到后退出循环
            }
        }
        return courses; // 返回找到的课程列表，如果没有找到则返回空列表
    }
}
